package com.shuai.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class RemoveSessionServlet extends HttpServlet {
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    HttpSession session = req.getSession();

    resp.setContentType("text/html;charset=utf-8");
    req.setCharacterEncoding("utf-8");
    resp.setCharacterEncoding("utf-8");
    System.out.println("RemoveSessionServlet----已经进入doGet方法()");

    // session失效
    session.invalidate();
    resp.getWriter().write("<h1>Session已经失效了</h1>");
  }
}
